package com.atguigu.distributed.lock.controller;

import com.atguigu.distributed.lock.redis.service.RedisStockService;
import com.atguigu.distributed.lock.service.StockService;
import com.atguigu.distributed.lock.zookeeper.curator.service.CuratorStockService;
import com.atguigu.distributed.lock.zookeeper.service.ZookeeperStockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StockController {

    @Autowired
    private StockService stockService;

    @Autowired
    private RedisStockService redisStockService;

    @Autowired
    private ZookeeperStockService zookeeperStockService;

    @GetMapping("stock/deduct")
    public String deduct(){
        stockService.deduct4();
        return "hello stock deduct！！";
    }

    @GetMapping("redisStock/deduct")
    public String redisDeduct(){
        redisStockService.deduct2();
        return "hello redisStock redisDeduct！！";
    }

    @GetMapping("zookeeperStock/deduct")
    public String zookeeperDeduct(){
        zookeeperStockService.deduct1();
        return "hello zookeeperStock zookeeperDeduct！！";
    }

}
